package com.fuyao.cloud.asset.inventory.process;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fuyao.cloud.asset.card.service.AssetAssetcardService;
import com.fuyao.cloud.asset.card.wrappers.CardWrappersUtil;
import com.fuyao.cloud.asset.constant.AssetCardConstant;
import com.fuyao.cloud.asset.entity.AssetCard;
import com.fuyao.cloud.asset.enums.AssetStatusEnum;
import com.fuyao.cloud.asset.enums.CardStatusEnum;
import com.fuyao.cloud.asset.inventory.entity.InventoryTask;
import com.fuyao.cloud.asset.inventory.enums.InventoryTaskTypeEnum;
import org.apache.commons.compress.utils.Lists;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author lyhills
 * @Description
 * @date 2023/9/15 16:30
 * @Version 1.0
 */
@Service
@InventoryTaskType(value = "all")
public class InventoryAllAssetCard implements InventoryTaskTypeFactory {

    public InventoryAllAssetCard(){
        System.out.println("InventoryAllAssetCard初始化加载");
    }

    @Resource
    private AssetAssetcardService assetAssetcardService;

    @Override
    public String getType() {
        return InventoryTaskTypeEnum.ALL.getCode();
    }

    @Override
    public List<AssetCard> getAssetCardList(InventoryTask entity) {
        LambdaQueryWrapper<AssetCard> lambdaQueryWrapper = CardWrappersUtil.getAssetCardFilterStatusWrapper().in(StrUtil.isNotBlank(entity.getAssetStatus()), AssetCard::getStatus, StrUtil.split(entity.getAssetStatus(), ","));
        List<AssetCard> list = assetAssetcardService.list(lambdaQueryWrapper);
        System.out.printf("总找出资产数据共%s条", list.size());
        return list;
    }
}
